//not use  合并到了Route calss
class wayPoints
{
    static getInstance(){
        if(!wayPoints.instance){
              wayPoints.instance = new wayPoints();
        }
        return wayPoints.instance;
    }

    /**
     * 设置数据
     * @param routerId
     * @param data
     */
    setData(routerId , data){
        OBJECT.routerPonits[routerId]={}
        OBJECT.routerPonits[routerId].vehicleId = null;   //设置默认值
        OBJECT.routerPonits[routerId].driverId  =null;    //设置默认值
        OBJECT.routerPonits[routerId].points = data;
    }

    /**
     *
     * @param routerId
     * @returns {*}
     */
    getData( routerId ) {
        return OBJECT.routerPonits[routerId].points;
    }
    /**
     * 重新给路线排序
     * @param routerId
     */
    reOrder( routerId ){
         let wayPonits = OBJECT.directionsDisplay[routerId].getDirections();
         let len = OBJECT.routerPonits[routerId].points.length;
         let orders =  wayPonits.routes[0].waypoint_order ;
         let newWayPoints = [];
             newWayPoints.unshift( OBJECT.routerPonits[routerId].points[0])
         orders.forEach( function ( value ,index ) {
             newWayPoints.push( OBJECT.routerPonits[routerId].points[value] )
         })
         newWayPoints.push( OBJECT.routerPonits[routerId].points[ len - 1] )
         OBJECT.routerPonits[routerId].points = newWayPoints;
    }

    /**
     * 设置路线每个点之间的时间和路程
     * @param routerId
     */
    setRouteSchedule ( routerId ) {
        let wayPonits = OBJECT.directionsDisplay[routerId].getDirections();
        let len = OBJECT.routerPonits[routerId].points.length;
        let schedule =  wayPonits.routes[0].legs;
        let ret = [];
        schedule.forEach(function ( value , index ) {
             let t ={distance:value.distance.text,duration:value.duration.text};
             ret.push( t );
        })
        OBJECT.routeSchedule[ routerId ] = ret;

    }

    /**
     * 获取路线每个点之间的时间和路程
     * @param routerId
     * @returns {*}
     */
    getRouteSchedule ( routerId ) {
        return OBJECT.routeSchedule[ routerId ] ;
    }
}
